package com.ruoyi.system.dao;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.ruoyi.common.core.domain.entity.SysUser;

@Repository
public interface SysUserDAO
		extends JpaRepository<SysUser, String>, JpaSpecificationExecutor<SysUser>, Serializable {
	
	
	public List<SysUser> findByUserName(String userName);
	
	
	public SysUser findByPhonenumber(String phonenumber);
	
	
	
	public SysUser findByEmail(String email);
	
	@Modifying
	@Query(value = "update sys_user set avatar =?2 where user_name =?1", nativeQuery = true)
	public int updateUserAvatar(String userName, String avatar );


	@Modifying
	@Query(value = "update sys_user set password =?2 where user_id =?1", nativeQuery = true)
	public int resetUserPwd(String userId, String password );
	
	@Modifying
	@Query(value = "update sys_user set login_ip =?2,login_date=?3 where user_id =?1", nativeQuery = true)
	public int updateUserLoginInfo(String userId,String loginIp,Date loginDate);

	@Query(value = "select password from sys_user  where user_id =?1", nativeQuery = true)
	public String findPasswordByUserId(String userId);
}
